package xin.zhiyin.控制.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import xin.zhiyin.实体.系统菜单Entity;
import xin.zhiyin.服务.系统菜单Service;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(path = "/system")//页面的url地址
public class 系统后台首页Controller {
    @Autowired
    private 系统菜单Service 菜单Service;
    @GetMapping(path = "/main")
    public String 系统后台概览(Model model){
        model.addAttribute("captchaType","math");
        return "system/main";
    }
    @RequestMapping({"","/","/index"})
    public String 后台首页(Model model){
        List<系统菜单Entity> 总菜单列表 = new ArrayList<系统菜单Entity>();
        List<系统菜单Entity> 顶部菜单列表 = new ArrayList<系统菜单Entity>();
        总菜单列表 = 菜单Service.获取所有系统菜单();
        for(int i=0;i<总菜单列表.size();i++){
            if(总菜单列表.get(i).getParentId()==0)
            {
                顶部菜单列表.add(总菜单列表.get(i));
            }
        }
        model.addAttribute("topMenuList",顶部菜单列表);
        return "/system/index";
    }
}
